public class Test {
    public static void loginInfo(String userName,String passWord) throws UserNameException,PassWordException {
        String username = "nobody";
        String password = "123456";
        if(!userName.equals(username)){
            throw new UserNameException("用户名错误！");
        }
        if(!passWord.equals(password)){
            throw new PassWordException("密码错误！");
        }
        System.out.println("登陆成功！");
    }
    public static void main(String[] args) {
        try{
            loginInfo("nobody","123456");
        }catch(UserNameException | PassWordException e){
            e.printStackTrace();
        }
    }
}

